/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server;

import java.io.PrintWriter;

/**
 *
 * @author spider391Tang
 */
class change extends ChatFormat implements BroadcastMsg {

    public change(String line) {

        super(line);

    }

    public void sendMsg(PrintWriter out, KKMultiServerThread server) {
        String name = server.getUser();
        server.send_change_client(out, msg);

    }

    public void execute(KKMultiServerThread server) {

        String[] names = msg.split(" ");
        /// 公子乖 -　
        // names[0] => yoyo-1
        // names[1] => x
        // names[2] => y

        // /obj yoyo chat.CircleBean 369 175 #ff0000 #00ff00 30
        //String org_msg = server.getMsgQueue().
        String org = server.getWbMsgQueue().get(names[0]);
        //System.out.println(org);
        String[] orgnames = org.split(" ");

        String newmsg = "";
        newmsg= orgnames[0] + " " + orgnames[1] + " " +  orgnames[2];

        for (int i = 1; i < names.length ; i++) {
            newmsg = newmsg.concat(" " + names[i]);
        }
        server.getWbMsgQueue().remove(names[0]);
        server.getWbMsgQueue().put(names[0], newmsg);

        //server.getWbMsgQueue().put(names[0], msg.substring(names[0].length()+1));

        server.broadcast(this);
    }
}

